#ifndef _VIZ_GRID_H_

#define _VIZ_GRID_H_

#include "grid.h"
#include "common.h"

namespace util {

template <class itype , class dtype , int dim > 
  void vizGrid( pavan::grid<itype,dtype,dim> &gg , const char *file ){
  const DECL_BLOCK_VEC( itype , dtype , dim ) &bv = gg.getAllBlocks();
  std::ofstream fout( file );
  fout << "VARIABLES=\"X\",\"Y\"\n" ;
  for( int ib = 0 ; ib < bv.size() ; ++ib ) {
    const DECL_BZ_VEC( double , dim ) &coord = gg.getBlockCoords( ib );
    fout << "ZONE ";
    for( int id = 0 ; id < dim ; ++id )
      fout << _nameIJK[id] << "=" << coord.shape()[id] << "  ";
    fout << " DATAPACKING = BLOCK\n";
    for( int m = 0 ; m < dim ; ++m )
      std::cout << "lbound("<< m << ") = " << coord[0].lbound(m)
                << "  ubound("<< m << ") = " << coord[0].ubound(m)
                << "\n";
    if( dim == 2 )
      DECL_LOOP_2( coord , itype , dim )
        fout << coord[ivar](i,j) << "\n";
 
    if( dim == 3 )
      DECL_LOOP_3( coord , itype , dim )
        fout << coord[ivar](i,j,k) << "\n";
  }
} 

}

#endif
